package com.element.oauth2.utils;

import org.springframework.util.AntPathMatcher;
import org.springframework.util.CollectionUtils;

import java.util.List;
import java.util.Set;

public class PathMatcherUtil {

    private final static AntPathMatcher matcher = new AntPathMatcher();

    public static boolean hasMatcher(List<String> urls, String path) {
        if (!CollectionUtils.isEmpty(urls)) {
            for (String url : urls) {
                if (matcher.match(url, path)) {
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean hasMatcher(Set<String> urls, String path) {
        if (!CollectionUtils.isEmpty(urls)) {
            for (String url : urls) {
                if (matcher.match(url, path)) {
                    return true;
                }
            }
        }
        return false;
    }
}